//
//  infoViewController.m
//  pocker_forTest
//
//  Created by Sui Seedorf on 12-7-10.  //  Copyright 2012 __MyCompanyName__. All rights reserved.
//

#import "infoViewController.h"
#import "pocker_forTestAppDelegate.h"
#import "PockerGroup.h";
#import "CustomCell.h";
@implementation infoViewController
@synthesize typeArray;
@synthesize myCell;
@synthesize myList;
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
	return 1;
}
- (NSInteger)tableView:(UITableView *)tableView
 numberOfRowsInSection:(NSInteger)section 
{
	//return [dataItems count]; 
	return [self.typeArray count]; 
	//return [self.myList count]; 

}


// Customize the appearance of table view cells.
/*-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath  
{  
	NSLog(@"楚华");
	 static NSString *tmpString=@"lll";  
	   UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:tmpString];  
	    if (cell==nil) {  
		       NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil];  
		        //这时myCell对象已经通过自定义xib文件生成了  
		        if ([nib count]>0) {  
			            cell = self.myCell;  
			           //加判断看是否成功实例化该cell，成功的话赋给cell用来返回。  
			        } else {  
				            NSLog(@"加载nib文件出错");  
				        }  
		    }  
	    NSInteger row=indexPath.row;  
	    UILabel *myLabel = (UILabel *)[cell viewWithTag:5 ];  
	    //这里的tag是在xib文件里面设的，用来找到我们设的label；  
	    myLabel.text=[myList objectAtIndex:row ];  
	   return cell;  
	      
	}  
*/
/*
 static NSString *CustomCellIdentifier = @"CustomCellIdentifier";
 
 static BOOL nibsRegistered = NO;
 if (!nibsRegistered) {
 UINib *nib = [UINib nibWithNibName:@"CustomCell" bundle:nil];
 [tableView registerNib:nib forCellReuseIdentifier:CustomCellIdentifier];
 nibsRegistered = YES;
 }
 
 CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CustomCellIdentifier];
 if (cell == nil) { 
 cell = [[CustomCell alloc] 
 initWithStyle:UITableViewCellStyleDefault 
 reuseIdentifier:CustomCellIdentifier]; 
 }
 UIImage *myImage = [UIImage imageNamed:@"ok.png"]; 
 
 cell.oneImageView=myImage;
 */
/*- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
	//CustomCell *cell = (CustomCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];  
    if (cell == nil) {
       cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
		 //cell= (CustomCell *)[[[NSBundle  mainBundle]  loadNibNamed:@"CustomCell" owner:self options:nil]  lastObject];  
    }
	NSUInteger row=[indexPath row];
	//[mstr appendString:ValueString];
	NSMutableString *mstr;
	PockerGroup *pg=[typeArray objectAtIndex:row];
	NSLog(@"pg.oneNum===%d",pg.oneNum);
	NSLog(@"pg.twoNum===%d",pg.twoNum);
	NSLog(@"pg.threeNum===%d",pg.threeNum);
	mstr=[NSMutableString stringWithFormat:@"%d", pg.oneNum];
		NSLog(@"mstr===%@",mstr);
	[mstr  appendString:@"+"];
	[mstr  appendString:[NSMutableString stringWithFormat:@"%d", pg.twoNum]];
	[mstr  appendString:@"+"];
	[mstr  appendString:[NSMutableString stringWithFormat:@"%d", pg.threeNum]];
	[mstr  appendString:@"="];
	[mstr  appendString:[NSMutableString stringWithFormat:@"%d",(pg.oneNum+pg.twoNum+ pg.threeNum)]];
	cell.textLabel.text=mstr;
	cell.imageView.image =[UIImage imageNamed:[NSString stringWithFormat:@"%@.png",@"ok"]];  
	//cell.oneImageView.image=[UIImage imageNamed:[NSString stringWithFormat:@"%@.png",@"ok"]];
    return cell;
}
*/
//改变行的高度


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
	
    return 110.0;
}

-(UITableViewCell *)tableView:(UITableView *)tableView
		cellForRowAtIndexPath:(NSIndexPath *)indexPath{
	CustomCell *cell=(CustomCell *)[tableView dequeueReusableCellWithIdentifier:@"CustomCellIdentifier"];
	
	if (cell==nil) {
		cell=[[UITableViewCell alloc]initWithFrame:CGRectZero reuseIdentifier:@"CustomCellIdentifier"];
		
		NSArray *nib=[[NSBundle mainBundle] loadNibNamed:@"CustomCell"
												   owner:self
												 options:nil];
		for (id oneObject in nib) {
			if ([oneObject isKindOfClass:[CustomCell class]]) {
				cell=(CustomCell *)oneObject;
			}
			
		}
	}
	
	NSInteger row=[indexPath row];
	//NSDictionary *rowData=[self.computer objectAtIndex:row];
	//cell.colorLabel.text=@"333";
	//cell.nameLabel.text=@"99";
	NSMutableString *mstr;
	PockerGroup *pg=[typeArray objectAtIndex:row];
	mstr=[NSMutableString stringWithFormat:@"%d", pg.oneNum];
	
	[mstr  appendString:@"+"];
	[mstr  appendString:[NSMutableString stringWithFormat:@"%d", pg.twoNum]];
	[mstr  appendString:@"+"];
	[mstr  appendString:[NSMutableString stringWithFormat:@"%d", pg.threeNum]];
	[mstr  appendString:@"="];
	[mstr  appendString:[NSMutableString stringWithFormat:@"%d",(pg.oneNum+pg.twoNum+ pg.threeNum)]];
	cell.nameLabel.text=[NSMutableString stringWithFormat:@"%d", (pg.oneNum+pg.twoNum+ pg.threeNum)];
	
	NSMutableString *mstrone;
	mstrone=[NSMutableString stringWithString:pg.oneType];
	[mstrone  appendString:[NSMutableString stringWithFormat:@"%d", pg.oneNum]];
	NSLog(@"mstrone===%@",mstrone);
	cell.oneImageView.image=[UIImage imageNamed:[NSString stringWithFormat:@"%@.png",mstrone]];  
	
	//2
	NSMutableString *mstrtwo;
	mstrtwo=[NSMutableString stringWithString:pg.twoType];
	[mstrtwo  appendString:[NSMutableString stringWithFormat:@"%d", pg.twoNum]];
	NSLog(@"mstrtwo===%@",mstrtwo);
	cell.twoImageView.image=[UIImage imageNamed:[NSString stringWithFormat:@"%@.png",mstrtwo]];  
	//3
	NSMutableString *mstrthree;
	mstrthree=[NSMutableString stringWithString:pg.threeType];
	[mstrthree  appendString:[NSMutableString stringWithFormat:@"%d", pg.threeNum]];
	cell.threeImageView.image=[UIImage imageNamed:[NSString stringWithFormat:@"%@.png",mstrthree]]; 
	NSLog(@"mstrthree===%@",mstrthree);
	cell.threeImageView.image=[UIImage imageNamed:[NSString stringWithFormat:@"%@.png",mstrthree]]; 
	
	return cell;
	
}

// The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
/*
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization.
    }
    return self;
}
*/

/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
}
*/
- (void)viewDidLoad {
	
	//pocker_forTestAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
	//NSLog(@"appDelegate.name=%@",appDelegate.name);
    [super viewDidLoad];
	 dataItems=[[NSMutableArray alloc]initWithObjects:@"中国",@"美国",@"日本",nil];  
	 myList = [NSArray arrayWithObjects:@"不",@"图",@"不",@"挂", nil];  
	//NSLog(@"myList count is= %d",self.myList.count);
	NSLog(@"self.typeArray.count===%d",self.typeArray.count);

	
}
/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations.
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- ( void ) loadView { 
	NSLog(@"TESfff");
	 UIView *view = [ [ UIView alloc] initWithFrame:[ UIScreen 
													 mainScreen] .applicationFrame] ; 
	 //[ view setBackgroundColor:_color] ; 
	 self.view = view; 
	 [ view release] ; 
 }  */
- (void)didReceiveMemoryWarning {
	//NSLog(@"TES22222222");
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc. that aren't in use.
}

- (void)viewDidUnload {
	//NSLog(@"TEST1111111111111111");
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
}


@end
